#ifndef LINECHART_H
#define LINECHART_H

#include <QWidget>
#include<QVector>

class LineChart:public QWidget
{
public:
    explicit LineChart(QWidget *parent=0);

    ~LineChart();
public:
    //  自定义的结构体
    struct MyPoint
    {
        float X;
        float Y;
    };


protected:
    void paintEvent(QPaintEvent *);

private:
    QPointF centerPoint;
    // 水平方向的最小值
    float minValueX;
    // 竖直方向的最小值
    float minValueY;

    float center_x;
    float center_y;

    //  垂直方向刻度间隔
    float scaleIntervelX=1.0f;
    float scaleIntervelY=1.0f;

    //  缩放因子
    float zoomFactorX=1.0f;
    float zoomFactorY=1.0f;

    QColor textColor;

     // 折线的颜色
    QColor lineColor;

    float index=0;
    QVector<MyPoint> points;

private slots:

    void drawHor(QPainter* painter, float centerY, float width);

    void drawVer(QPainter *painter, float centerX, float height);

    void drawPoints(QPainter *painter);

public:
    void addPoint(float valueY);    // 添加纵坐标值

};

#endif // LINECHART_H
